//
//  H5ViewController.swift
//  PICCRisk
//
//  Created by Denny on 2022/12/23.
//  Copyright © 2022 刘转. All rights reserved.
//

import UIKit
import WebKit
class H5ViewController:MYGBaseController, WKUIDelegate {
//    deinit {
//        self.observation = nil
//        self.webview.removeObserver(self, forKeyPath: "URL")
//    }
    var url:String = ""
    var progressView : UIProgressView = {
        let control = UIProgressView()
        control.trackTintColor = .white
        control.progressTintColor = .red
        return control
    }()
    lazy var webview: WKWebView = {
        let wkConfi = WKWebViewConfiguration.init()
        wkConfi.allowsInlineMediaPlayback = true
        let webView = WKWebView(frame: CGRect.zero, configuration: wkConfi)
        webView.isOpaque = false
        webView.scrollView.showsHorizontalScrollIndicator = false
        webView.scrollView.showsVerticalScrollIndicator = false
//        webView.addObserver(self, forKeyPath: "URL", context: nil)
        return webView
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        setUpUI()
//        MYGLoading.show()
        self.webview.loadURL(URL(string: self.url)!)
    }

    @objc override func backAction() {
        MYGLoading.hide()
        self.navigationController?.popViewController()
    }
    func setUpUI(){
        self.view.addSubview(webview)
        webview.snp.makeConstraints { make in
            make.left.right.equalTo(0)
            make.bottom.equalToSuperview()
            make.top.equalTo(0)
        }
    }

    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        MYGLoading.hide()
    }
  
}
